/**
 * @filename:DocumentShareDao 2025-04-27
 * @project starhub-schema  V1.0
 */
package com.starhub.engine.document.dao;


import com.starhub.engine.document.entity.DocumentShare;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**   
 * @Description:(附件管理数据访问层)
 * @version: V1.0
 * @author: 孙赛赛-sss
 * 
 */
@Mapper
public interface DocumentShareDao {

    /**
    *插入所有字段DocumentShare
    */
    int insert(DocumentShare record);

    int deleteDirectoryShare(@Param("userId") Long userId,@Param("permission") Integer permission,@Param("directoryId") Long directoryId);

    /**
    *插入非空字段DocumentShare
    *@param record
    */
    int insertSelective(DocumentShare record);

    /**
    *批量删除DocumentShare，物理删除
    */
    int  deleteDocumentShareRecord(@Param("idList") List<Long> idList);

    /**
     *
     * @param idList
     * @return
     */
    int  deleteDocumentShareByFileId(@Param("idList") List<Long> idList);


    /**
     *
     * @param fileId
     * @param directoryId
     * @return
     */
    int  deleteDocumentShareByFileDirId(@Param("fileId") Long fileId,@Param("directoryId") Long directoryId);

     /**
     *
     * @param directoryId
     * @return
     */
     List<DocumentShare> getDirectoryShareById(@Param("directoryId") Long directoryId,@Param("userId") Long userId);

    /**
     *
     * @param directoryId
     * @return
     */
    List<DocumentShare> getDirectoriesById(@Param("directoryId") Long directoryId);

    /**
     *
     * @param fileId
     * @param userId
     * @return
     */
    List<DocumentShare> getDocumentShareById(@Param("fileId") Long fileId,@Param("userId") Long userId);

    /**
     *
     * @param idList
     * @param userId
     * @return
     */
    List<DocumentShare> getDocumentSharesById(@Param("idList") List<Long> idList,@Param("userId") Long userId);

    /**
     *
     * @param idList
     * @param userId
     * @return
     */
    List<DocumentShare> getDirectorySharesById(@Param("idList") List<Long> idList,@Param("userId") Long userId);

    /**
     *根据DocumentShare对象,更新记录,仅更新非空字段
     *@param record
     */
     int updateByPrimaryKeySelective(DocumentShare record);

     /**
     *根据DocumentShare对象，更新记录
     *@param record
     */
     int updateByPrimaryKey(DocumentShare record);


    /**
    *根据id，查询DocumentShare对象
    *@param id 记录id
    */
    DocumentShare selectByPrimaryKey(@Param("id") Long id);

    DocumentShare checkPermissionByDirUserId(@Param("directoryId") Long directoryId,@Param("userId") Long userId,@Param("permission") Integer permission);

}